SPB Git forge
7commits 1branches 0releases
229.0 KBsize
maindefault branch
13 days agolast push
TypeScript 91.8% HTML 3.2% JavaScript 3% SQL 1.4% CSS 0.7%
905 B · 16 lines typescript
Raw Blame History
1import { cookies } from "next/headers";2import { NextResponse, type NextRequest } from "next/server";3import { COOKIE, verifyToken } from "@/lib/auth";45export const dynamic = "force-dynamic";6const API_URL = process.env.API_URL ?? "http://127.0.0.1:8350";78/** Sampled video frames, served through the gate. */9export async function GET(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {10  const jar = await cookies();11  if (!verifyToken(jar.get(COOKIE)?.value)) return NextResponse.json({ error: "unauthorized" }, { status: 401 });12  const { path } = await ctx.params;13  const upstream = await fetch(new URL(`/media/${path.map(encodeURIComponent).join("/")}`, API_URL), { cache: "no-store" });14  return new Response(upstream.body, { status: upstream.status, headers: { "content-type": upstream.headers.get("content-type") ?? "image/jpeg", "cache-control": "private, max-age=3600" } });15}16